package test.testcase.dao;

import test.utils.JsonResult;
import test.utils.Mysql;

public class ChannelDao {
	
	public static JsonResult list() {
		return Mysql.select("select * from channel where status=1");
	}
	
	public static JsonResult list(String projectid) {
		return Mysql.select("SELECT a.`channel_name` AS name FROM `project_channel` a LEFT JOIN `channel` b ON a.`channel_name`=b.`name` WHERE a.`projectid`="+projectid);
	}
	
	public static JsonResult add(String name) {
		return Mysql.excute("insert into channel values('"+name+"',1)");
	}
	
	public static JsonResult del(String name) {
		return Mysql.excute("update channel set status=0 where name='"+name+"'");
	}
	
	public static JsonResult delProjectChannel(String projectId) {
		return Mysql.excute("delete from project_channel where projectid='"+projectId+"'");
	}
	
	public static JsonResult add2toProject(String name, String projectId) {
		return Mysql.excute("insert into project_channel values ('"+projectId+"', '"+name+"')");
	}
	
}
